package com.example.demothree.service.imp;

import com.example.demothree.bean.Stock;
import com.example.demothree.dao.StockDao;
import com.example.demothree.service.SkService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SkServiceImp implements SkService {
    @Resource
    private StockDao stockDao;

    @Override
    public Page<Stock> skspck(Integer page, Integer size) {
        Pageable pageable = PageRequest.of(page,size);
        Page<Stock> pagespck = stockDao.findAll(pageable);
        return pagespck;
    }
    @Override
    public Page<Stock> skspyk(Integer page, Integer size) {
        Pageable pageable = PageRequest.of(page,size);
        Page<Stock> pagespyk = stockDao.findAll(pageable);
        return pagespyk;
    }
    //库存id查询
    @Override
    public Stock findkcykBy(Long id) {
        return stockDao.findStockById(id);
    }
    //添加库存
    @Override
    public Stock addkc(Stock stock) {
        return stockDao.save(stock);
    }
    //商品id查询
    @Override
    public Stock findspidBy(Long spid) {
        return stockDao.findStockBygoodsId(spid);
    }
}
